import org.apache.kudu.client.*;

// 查询数据
public class SelectDemo {
    public static void main(String[] args) {
        // 获取client
        String masterAdd = "server2";
        KuduClient.KuduClientBuilder kcb= new KuduClient.KuduClientBuilder(masterAdd);
        kcb.defaultSocketReadTimeoutMs(6000);
        KuduClient client = kcb.build();

        try {
            // 获取Scanner
            KuduTable table = client.openTable("student");
            KuduScanner scanner = client.newScannerBuilder(table).build();
            // 从Scanner中循环遍历数据
            while (scanner.hasMoreRows()){
                for (RowResult result : scanner.nextRows()){
                    int id = result.getInt("id");
                    String name = result.getString("name");
                    System.out.println(id + "\t" + name);
                }
            }
        } catch (KuduException e) {
            e.printStackTrace();
        } finally {
            try {
                client.close();
            } catch (KuduException e) {
                e.printStackTrace();
            }
        }
    }
}
